package com.java.comprehensive.arithmetic.leecode.easy;

import java.util.LinkedList;
import java.util.List;

public class LeetCode_242 {

    public static boolean isAnagram(String s, String t) {

        if (s.length() != t.length()) return false;
        List<Character> list = new LinkedList<>();
        for (int i = 0; i < s.length(); i++) {
            list.add(s.charAt(i));
        }
        for (int i = 0; i < t.length(); i++) {
            Character c = t.charAt(i);
            list.remove(c);
        }
        return list.isEmpty();
    }

    public static void main(String[] args) {
        String s = "anagram", t = "nagaram";
        System.out.println(isAnagram(s, t));
    }
}
